// 简单动态规划
// 还是自己先来尝试一下吧

#include <iostream>
#include <vector>

using namespace std;
const int N = 510;
char a[N][N];
int ret[N][N];
int n, m;

int main(){

    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            cin >> a[i][j];

        }
    }
    // 开始动态规划
        for (int i = 1; i <= n; i++){
        for (int j = 1; j <= m; j++){
            int x = 0;
            if (a[i][j] == 'l') x += 4;
            else if (a[i][j] == 'o') x += 3;
            else if (a[i][j] == 'v') x += 2;
            else if (a[i][j] == 'e') x += 1;
            ret[i][j] = max(ret[i - 1][j], ret[i][j - 1]) + x;
        }
    }
    cout << ret[n][m] << endl;
    return 0;
}